﻿@using MrCMS.Entities.Widget
@using MrCMS.Helpers
@model MrCMS.Models.PageWidgetSortModel
@{
    ViewBag.Title = "Sort Webpage";
    Layout = "~/Areas/Admin/Views/Shared/_LayoutPopup.cshtml";

    var action = Model.WebpageId > 0 ? "SortWidgetsForPage" : "SortWidgetsAction";

}
@{Html.IncludeScript("~/Areas/Admin/Content/Scripts/mrcms/sort.js");}

@using (Html.BeginForm(action, "LayoutArea", FormMethod.Post, new { id = "edit-sort" }))
{

    @Html.Hidden("returnUrl", ViewData["returnUrl"])
    @Html.Hidden("LayoutAreaId", Model.LayoutAreaId)
    <fieldset>
        <legend>
            @Resource("Admin Sort Widgets Title", "Sort Widgets")
        <span class="btn-group  display-inline  pull-right">
            <button class="btn btn-primary">@Resource("Save")</button>
            </span>
        </legend>

        <ul id="sortable">
            @for (int i = 0; i < Model.Widgets.Count; i++)
            {
                var widget = Model.Widgets[i];
                <li>
                    @Html.HiddenFor(model => model.Widgets[i].Id)
                    @Html.HiddenFor(model => model.Widgets[i].Order)
                    <i class="glyphicon glyphicon-resize-full"></i>&nbsp;&nbsp;
                    @widget.Name
                </li>
            }
        </ul>
    </fieldset>
}
@Html.InfoBlock(Resource("Heads up") + "!", Resource("Admin Widgets Sort info", "Drag items in to the order you would like then click save."))
